find all possible paths between two points in a matrix